<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta http-equiv="cache-control" content="no-cache">
<title>Genivia - Test Messenger</title>
<link href="genivia_tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="genivia_content.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="top">
 <div id="titlearea">
  <table height="72px" width="100%" cellspacing="0" cellpadding="0">
   <tbody>
    <tr>
     <td width="10%">&nbsp;</td>
     <td width="175px"><a href="https://www.genivia.com"><img alt="Genivia" src="GeniviaLogo2_trans_noslogan.png"/></a></td>
     <td class="tab_home"><a href="https://www.genivia.com">Home</a></td>
     <td class="tab_home"><a href="https://www.genivia.com/docs.html">Documentation</a></td>
     <td>
      <div style="float: right; font-size: 18px; font-weight: bold;">Test Messenger</div>
      <br>
      <div style="float: right; font-size: 10px;">updated Sun Feb 16 2020 by Robert van Engelen</div>
     </td>
     <td width="10%">&nbsp;</td>
    </tr>
   </tbody>
  </table>
 </div>
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li class="current"><a href="index.html"><span>Main&#160;Page</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Test Messenger </div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#intro">Introduction                                                            </a></li>
<li class="level1"><a href="#build">Building and installing testmsgr                                        </a></li>
<li class="level1"><a href="#using">Using testmsgr                                                          </a><ul><li class="level2"><a href="#servers">Server-side testing                                                   </a></li>
<li class="level2"><a href="#clients">Client-side testing                                                   </a></li>
<li class="level2"><a href="#options">Options                                                               </a></li>
</ul>
</li>
<li class="level1"><a href="#templates">Message templates                                                   </a><ul><li class="level2"><a href="#placeholder">Placeholder values                                                </a></li>
<li class="level2"><a href="#indicators">Element repetition, selection and permutation indicators           </a></li>
</ul>
</li>
<li class="level1"><a href="#copyright">Copyright                                                           </a></li>
</ul>
</div>
<div class="textblock"><h1><a class="anchor" id="intro"></a>
Introduction                                                            </h1>
<p>The Test Messenger tool is an advanced "fuzzer" software testing tool to test XML SOAP and REST Web services and client applications. Testing is performed by sending XML test messages (randomized in case of fuzzing) to services and client applications.</p>
<p>It is important to test Web services and client applications as part of a quality assurance process. Furthermore, the functional and non-functional requirements of an application should be verified and tested before the application is deployed in the field. Testing Web services with randomized message exchange patterns can help to pinpoint problems early on, before applications are deployed.</p>
<p>The benefit of the Test Messenger is the ability to use a set of message templates for unit and regression testing, and "fuzz testing" with randomization of XML attribute and element values in the message templates, including the generation of input errors, when specified. Randomization is driven by XML annotations in the message templates. These message templates are automatically generated by soapcpp2 with option <code>-g</code>.</p>
<p>The Test Messenger tool is executed from the command line or from a shell script, such as a script intended to test services and clients. No coding is required to use the Test Messenger.</p>
<p>The testmsgr Test Messenger tool is located in the gSOAP distribution package under <code>gsoap/samples/testmsgr</code> and is built with: </p><pre class="fragment">cd gsoap/samples/testmsgr
make
</pre><p>To generate randomized XML messages with the Test Messenger, a SOAP/XML message template is required. The Test Messenger populates the template with random values to send the randomly populated SOAP/XML request message to a service for <a class="el" href="index.html#servers">Server-side testing </a>. Or the Test Messenger can be started as a stand-alone server to return the randomly populated response message template to a client for <a class="el" href="index.html#clients">Client-side testing </a>.</p>
<p>You can create a SOAP/XML message template manually or auto-generate it with soapcpp2 option <code>-g</code>. For example, to auto-generate XML sample message templates from an interface header file <code>file.h</code> (e.g. generated with wsdl2h from WSDLs), use soapcpp2 with option <code>-g</code>: </p><pre class="fragment">soapcpp2 -g file.h
</pre><p>The soapcpp2 tool generates sample messages for the service operations defined in <code>file.h</code>. Option <code>-g</code> changes the sample message to message templates that contain placeholders of the form <code>%[...]%</code>. A leading <code>???</code> qualifier indicates optional elements and attributes. Repeated elements and/or CDATA is indicated and enclosed in <code>&lt;__REPEAT&gt;</code>...<code>&lt;/__REPEAT&gt;</code>. Element selections are indicated and enclosed as child elements in <code>&lt;__SELECT&gt;</code>...<code>&lt;/__SELECT&gt;</code>. Element permutations are enclosed as child elements in <code>&lt;__PERMUTE&gt;</code>...<code>&lt;/__PERMUTE&gt;</code>.</p>
<p>A placeholder value <code>%[...]%</code> specifies an XSD-related type, enumeration, or numeric range. These placeholders are populated by the Test Messenger using random values that conform to the placeholder's specified value type.</p>
<p>While the sample messages generated by soapcpp2 (without option <code>-g</code>) can be used to test clients and services as explained in the gSOAP user guide, the problem is that the content of the sample messages is always fixed. This provides only very limited testing capabilities. By contrast, the Test Messenger tool generates randomized messages based on SOAP/XML message templates for enhanced testing of client and service applications.</p>
<p>The Test Messenger is intended to test common messaging scenarios that are defined by SOAP/XML message templates. The Test Messenger does not add (random) XML attributes and elements that are not already in the message template. It can randomly remove attributes and elements with option <code>-p</code> to test the robustness of an application to consuming partial and possibly invalid XML messages (invalid according to the schema of the XML message).</p>
<p>The Test Messenger has several options to further randomize the messages by randomly removing attributes and elements at a specific rate of chance, or to add random spacing to XML attribute and element values, and to continuously test a service until it fails.</p>
<p>To demonstrate the Test Messenger, assume we have the following services declared in the interface <code>file.h</code>:</p>
<div class="fragment"><div class="line"><span class="comment">//gsoap ns service name:      example</span></div><div class="line"><span class="comment">//gsoap ns service namespace: urn:example</span></div><div class="line"></div><div class="line"><span class="preprocessor">#import &quot;custom/struct_tm.h&quot;</span>        <span class="comment">// use struct tm for xsd:dateTime</span></div><div class="line"></div><div class="line"><span class="keyword">typedef</span> std::string xsd__ID;        <span class="comment">// declare xsd:ID type (whitespace collapsed)</span></div><div class="line"><span class="keyword">typedef</span> std::string xsd__Name;      <span class="comment">// declare xsd:Name type (whitespace collapsed)</span></div><div class="line"><span class="keyword">typedef</span> xsd__Name ns__name 1:80;    <span class="comment">// restrict xsd:Name to a name with 1 to 80 chars</span></div><div class="line"><span class="keyword">typedef</span> <span class="keywordtype">float</span> ns__miles 0: ;        <span class="comment">// restrict xsd:float to non-negative</span></div><div class="line"></div><div class="line"><span class="keyword">enum</span> ns__gender { male, female };</div><div class="line"></div><div class="line"><span class="keyword">struct </span>ns__person</div><div class="line">{</div><div class="line">  @xsd__ID        id;</div><div class="line">  ns__name        firstname;</div><div class="line">  ns__name        lastname;</div><div class="line">  xsd__dateTime   dob;</div><div class="line">  <span class="keyword">enum</span> ns__gender gender;</div><div class="line">  ns__miles      *miles;</div><div class="line">};</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> ns__upload(<span class="keyword">struct</span> ns__person *person, xsd__ID&amp; <span class="keywordtype">id</span>);   <span class="comment">// upload to DB</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> ns__download(xsd__ID <span class="keywordtype">id</span>, <span class="keyword">struct</span> ns__person&amp; person);  <span class="comment">// download from DB</span></div></div><!-- fragment --><p>We run soapcpp2 on this interface <code>file.h</code> with option <code>-g</code>: </p><pre class="fragment">soapcpp2 -g file.h
</pre><p>This produces the following SOAP/XML template files among other source code files:</p>
<ul>
<li><code>example.upload.req.xml</code> XML template upload request message</li>
<li><code>example.download.req.xml</code> XML template download request message</li>
<li><code>example.upload.res.xml</code> XML template upload response message</li>
<li><code>example.download.res.xml</code> XML template download response message</li>
</ul>
<p>The <code>example.upload.req.xml</code> file looks like this:</p>
<div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;?<span class="keyword">xml</span> <span class="keyword">version</span>=<span class="stringliteral">&quot;1.0&quot;</span> <span class="keyword">encoding</span>=<span class="stringliteral">&quot;UTF-8&quot;</span>?&gt;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;&lt;<span class="keywordtype">SOAP-ENV:Envelope</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  <span class="keyword">xmlns:SOAP-ENV</span>=<span class="stringliteral">&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;  <span class="keyword">xmlns:SOAP-ENC</span>=<span class="stringliteral">&quot;http://schemas.xmlsoap.org/soap/encoding/&quot;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;  <span class="keyword">xmlns:xsi</span>=<span class="stringliteral">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;  <span class="keyword">xmlns:xsd</span>=<span class="stringliteral">&quot;http://www.w3.org/2001/XMLSchema&quot;</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;  <span class="keyword">xmlns:ns</span>=<span class="stringliteral">&quot;urn:example&quot;</span>&gt;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160; &lt;<span class="keywordtype">SOAP-ENV:Body</span>&gt;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;  &lt;<span class="keywordtype">ns:upload</span>&gt;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;   &lt;<span class="keywordtype">person</span> <span class="keyword">id</span>=<span class="stringliteral">&quot;???%[[ID]]%&quot;</span>&gt;???</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;    &lt;<span class="keywordtype">firstname</span>&gt;%[[<span class="keyword">NAME</span>[1:80]]]%&lt;/<span class="keywordtype">firstname</span>&gt;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;    &lt;<span class="keywordtype">lastname</span>&gt;%[[<span class="keyword">NAME</span>[1:80]]]%&lt;/<span class="keywordtype">lastname</span>&gt;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;    &lt;<span class="keywordtype">dob</span>&gt;%[[<span class="keyword">DATETIME</span>]]%&lt;/<span class="keywordtype">dob</span>&gt;</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;    &lt;<span class="keywordtype">gender</span>&gt;%[[<span class="keyword">male</span>][<span class="keyword">female</span>]]%&lt;/<span class="keywordtype">gender</span>&gt;</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;    &lt;<span class="keywordtype">miles</span>&gt;???%[[0.000000<span class="keyword">E</span>+00:3.402823<span class="keyword">E</span>+38]]%&lt;/<span class="keywordtype">miles</span>&gt;</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;   &lt;/<span class="keywordtype">person</span>&gt;</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;  &lt;/<span class="keywordtype">ns:upload</span>&gt;</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160; &lt;/<span class="keywordtype">SOAP-ENV:Body</span>&gt;</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;&lt;/<span class="keywordtype">SOAP-ENV:Envelope</span>&gt;</div></div><!-- fragment --> </div><p>Note that XML values in this template are represented by value placeholders of the form <code>%[...]%</code>. Also note that the <code>person</code> element, the <code>id</code> attribute and <code>miles</code> are optional.</p>
<p>A leading <code>???</code> qualifier indicates optional elements and attributes, when the <code>???</code> qualifier appears after the opening tag of an element (i.e. in front of the element value or child elements) and in attribute values, respectively. For the full list of placeholders that can be used, see <a class="el" href="index.html#placeholder">Placeholder values </a>.</p>
<p>This message template is read, populated and then sent to the standard output by testmsgr as follows: </p><pre class="fragment">./testmsgr -r1 -i example.upload.req.xml
</pre><div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;Random seed = 1</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:SOAP-ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:ns=&quot;urn:example&quot;&gt;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160; &lt;SOAP-ENV:Body&gt;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;  &lt;ns:upload&gt;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;   &lt;person id=&quot;BAmlkjihg9876543210v.-zyxwvutsrqponmlkjihgfedcbas_qponZYXWVUTSRQPONMLKJIHGFEDCBAmlkjihg9876543210v.-zyxwvutsrqponmlkjihgfedcbas_qponZYXWVUTSRQPONMLKJIHGFEDCBAmlkjihg9876543210v.-zyxwvutsrqponmlkjihgfedcbas_qponZYXWVUTSRQPONMLKJIHGFEDCBAmlkjihg9876543210v.&quot;&gt;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;    &lt;firstname&gt;ghefklij_spqcdabWXUVnoYZOPMNSTQRGHEFKLIJlmjkCDAB7856hi9gv0&lt;/firstname&gt;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;    &lt;lastname&gt;QRSTMNOPYZnoUVWXabcdpq_sijklefgh1234&lt;/lastname&gt;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;    &lt;dob&gt;1969-12-31T23:59:59Z&lt;/dob&gt;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;    &lt;gender&gt;female&lt;/gender&gt;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;    &lt;miles&gt;8255613886394.9941&lt;/miles&gt;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;   &lt;/person&gt;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;  &lt;/ns:upload&gt;</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160; &lt;/SOAP-ENV:Body&gt;</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;&lt;/SOAP-ENV:Envelope&gt;</div></div><!-- fragment --> </div><p>This produced a randomized SOAP/XML message to standard output from the <code>example.upload.req.xml</code> template message. Option <code>-r1</code> sets the random seed to <code>1</code>. Any seed value between 1 and 2147483647 can be specified with <code>-r</code>. Option <code>-i</code> displays the randomized XML with indentation.</p>
<p>To randomly retain or discard optional elements and attributes, use option <code>-q</code> with a specified percentage to retain optional elements and attributes in the generated XML message: </p><pre class="fragment">./testmsgr -r1 -q50 -i example.upload.req.xml
</pre><p>This retains the optional element <code>person</code>, the <code>id</code> attribute, and the <code>miles</code> element with a 50% chance each.</p>
<p>To send the randomized SOAP/XML message to a service endpoint, pass the endpoint URL as the last argument to the testmsgr command: </p><pre class="fragment">./testmsgr -r1 -i example.upload.req.xml http://www.example.com/service
</pre><p>For example, we can let soapcpp2 generate a simple echo test service to which we can send messages. Since we auto-generate a simple echo test service we have no server-side logic to return meaningful values for this example.</p>
<p>First we invoke soapcpp2 with option <code>-T</code> to generate the server-side code for a simple test service: </p><pre class="fragment">soapcpp2 -g -SL -T file.h
</pre><p>This generates the SOAP/XML message templates and the following source code files:</p>
<ul>
<li><code>example.wsdl</code> a WSDL to publish the service</li>
<li><code>example.nsmap</code> an XML namespace mapping table to include in your source code</li>
<li><code>soapStub.h</code> annotated copy of the source interface file</li>
<li><code>soapH.h</code> serialization functions</li>
<li><code>soapC.cpp</code> serialization functions</li>
<li><code>soapServer.cpp</code> service request dispatcher</li>
<li><code>soapTester.cpp</code> auto-test echo server</li>
</ul>
<p>Next, we compile these files together with the gSOAP library and the custom serializer for <code>struct tm</code> to build a simple echo server: </p><pre class="fragment">c++ -I. -o echoserver soapTester.cpp soapServer.cpp soapC.cpp stdsoap2.cpp custom/struct_tm.c
</pre><p>Now run the server. For example with arguments 8080 as the port to bind to and 8192 to set the <code>SOAP_XML_INDENT</code> engine context flag: </p><pre class="fragment">./echoserver 8192 8080
</pre><p>Finally, let's fire a randomized message to the simple echo service, using the auto-generated <code>example.upload.req.xml</code> message template: </p><pre class="fragment">./testmsgr -r1 example.upload.req.xml http://localhost:8080
</pre><div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;Random seed = 1</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;Server response:</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;---- begin ----</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:SOAP-ENC=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:ns=&quot;urn:example&quot;&gt;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;        &lt;SOAP-ENV:Body&gt;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;                &lt;ns:uploadResponse&gt;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;                        &lt;id&gt;&lt;/id&gt;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;                &lt;/ns:uploadResponse&gt;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;        &lt;/SOAP-ENV:Body&gt;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;&lt;/SOAP-ENV:Envelope&gt;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;---- end ----</div></div><!-- fragment --> </div><p>The testmsgr displays the response received from the server, which for the simple echo service upload request is the upload response with an id element.</p>
<p>To send a continuous stream of randomized message to the server, use option <code>-c</code>: </p><pre class="fragment">./testmsgr -c -r1 example.upload.req.xml http://localhost:8080
</pre><p>This continous until the service fails. A test is reproduced by using its random seed. So if the service fails you can replicate the message with the random seed and option <code>-r</code> with this seed value.</p>
<p>The Test Messenger tool can also send pruned XML messages with option <code>-p</code>. Pruning means that attributes and elements are randomly discarded, which allows for testing the robustness of the service against incomplete and malformed SOAP/XML content: </p><pre class="fragment">./testmsgr -c -p80 -r1 example.upload.req.xml http://localhost:8080
</pre><p>Option <code>-p80</code> means that 80% is retained and 20% of attributes and elements are randomly discarded from the SOAP/XML template <code>example.upload.req.xml</code>.</p>
<p>When testing the auto-test echo service, the echo service displays failed requests and is silent for successful requests.</p>
<p>For the full list of testmsgr options, see <a class="el" href="index.html#options">Options </a>.</p>
<p>🔝 <a href="#">Back to table of contents</a></p>
<h1><a class="anchor" id="build"></a>
Building and installing testmsgr                                        </h1>
<p>To build testmsgr, <a href="http://www.genivia.com/downloads.html">install gSOAP</a> and build testmsgr as follows: </p><pre class="fragment">cd gsoap/samples/testmsgr
make testmsgr
</pre><p>This builds the command-line tool testmsgr in <code>gsoap/samples/testmsgr</code> from where you can use it and/or copy it for use with your projects.</p>
<p>If you do not have the samples built, you can use soapcpp2 from the command line to generate the C++ code required for testmsgr: </p><pre class="fragment">cd gsoap/samples/testmsgr
soapcpp2 -CSL ../../import/dom.h
c++ -I../.. -o testmsgr testmsgr.cpp soapC.cpp ../../dom.cpp ../../stdsoap2.cpp
</pre><p>This builds the testmsgr command-line tool.</p>
<p>For users of Windows, visit <a href="http://www.genivia.com/downloads.html">download and installation</a> to download <code>testmsgr.exe</code>.</p>
<p>🔝 <a href="#">Back to table of contents</a></p>
<h1><a class="anchor" id="using"></a>
Using testmsgr                                                          </h1>
<p>The testmsgr command takes a set of options, a SOAP/XML message file or a message template file (i.e. to randomize with option <code>-r</code>), and an optional service endpoint URL.</p>
<p>🔝 <a href="#">Back to table of contents</a></p>
<h2><a class="anchor" id="servers"></a>
Server-side testing                                                   </h2>
<p>To test services, run testmsgr against the service endpoint URL, for example when the service runs on the localhost on port 8080: </p><pre class="fragment">./testmsgr -r99 example.upload.req.xml http://localhost:8080
</pre><p>When using https endpoints, you must build testmsgr with compile-time flag <code>WITH_OPENSSL</code> and link OpenSSL as follows: </p><pre class="fragment">soapcpp2 -CSL ../../import/dom.h
c++ -DWITH_OPENSSL -o testmsgr testmsgr.cpp soapC.cpp ../../dom.cpp ../../stdsoap2.cpp -lssl -lcrypto
</pre><p>For CGI-based services that read SOAP/XML requests from standard input you can redirect the (randomized) message to the CGI-based service. For example: </p><pre class="fragment">./testmsgr -r99 example.upload.req.xml | ./echoserver
</pre><p>where echoserver is a CGI-based service (the echoserver built in the <a class="el" href="index.html#intro">Introduction </a> uses CGI by default).</p>
<p>🔝 <a href="#">Back to table of contents</a></p>
<h2><a class="anchor" id="clients"></a>
Client-side testing                                                   </h2>
<p>To test clients, run testmsgr as a stand-alone server by specifying a port number instead of a service endpoint URL: </p><pre class="fragment">./testmsgr -r1 example.download.res.xml 8080
</pre><p>This runs the Test Messenger on port 8080. The Test Messenger discards request messages sent by clients and returns randomized responses using the SOAP/XML <code>example.download.res.xml</code> response message template.</p>
<p>You can also use file redirection to test clients when your client uses the "http://" endpoint URL without a domain. By using this URL your client writes HTTP messages to standard output and reads HTTP responses from standard input. For example: </p><pre class="fragment">./testmsgr -r1 example.download.res.xml &gt; response.xml
./client &lt; response.xml &gt; /dev/null
</pre><p>🔝 <a href="#">Back to table of contents</a></p>
<h2><a class="anchor" id="options"></a>
Options                                                               </h2>
<pre class="fragment">testmsgr [-aact] [-b] [-c] [-dnum] [-f] [-h] [-i] [-j] [-lmax] [-mmax]
         [-nlen] [-ofile] [-pnum] [-qnum] [-rseed] [-tsec] [-v] [-A]
         [-C] [-H] [-M] [-Oopt] [-Pper] [-Rrep] [-Ssel]
         [-Xuid:pwd] [-Yhost[:port[:uid:pwd]]] [infile|-] [URL|port]
</pre><p>where the testmsgr command-line options are:</p>
<table class="doxtable">
<tr>
<th>Option </th><th>Description  </th></tr>
<tr>
<td><code>-a act</code> </td><td>add a HTTP SOAP Action header value <code>"act"</code> </td></tr>
<tr>
<td><code>-b</code> </td><td>add random spacing to randomized values when using <code>-r</code> </td></tr>
<tr>
<td><code>-c</code> </td><td>continuous testing until the service endpoint fails, when using a URL </td></tr>
<tr>
<td><code>-d num</code> </td><td>test a service endpoint <code>num</code> times or until it fails, when using a URL </td></tr>
<tr>
<td><code>-f</code> </td><td>exit on any HTTP error or SOAP fault when using <code>-c</code> or <code>-d</code> </td></tr>
<tr>
<td><code>-h</code> </td><td>display help message </td></tr>
<tr>
<td><code>-i</code> </td><td>indent XML with spaces when using <code>-r</code> </td></tr>
<tr>
<td><code>-j</code> </td><td>indent XML with tabs when using <code>-r</code> </td></tr>
<tr>
<td><code>-l max</code> </td><td>max number of randomized element repeats when using <code>-r</code> (default is 3) </td></tr>
<tr>
<td><code>-m max</code> </td><td>max length of randomized text values generated (default is 10) </td></tr>
<tr>
<td><code>-n len</code> </td><td>display the server response up to len bytes </td></tr>
<tr>
<td><code>-o file</code> </td><td>save to file instead of stdout </td></tr>
<tr>
<td><code>-p perc</code> </td><td>percentage of XML kept in general when using -r (default=100) </td></tr>
<tr>
<td><code>-q perc</code> </td><td>percentage of XML kept of optional/repeated indicators when using -r (default=100) </td></tr>
<tr>
<td><code>-r seed</code> </td><td>randomize XML from XML message templates (use soapcpp2 <code>-g</code>) </td></tr>
<tr>
<td><code>-t sec</code> </td><td>socket idle timeout seconds (default=1), to test response time </td></tr>
<tr>
<td><code>-v</code> </td><td>verbose mode </td></tr>
<tr>
<td><code>-A</code> </td><td>enable SOAP with MIME attachments (SwA) </td></tr>
<tr>
<td><code>-C</code> </td><td>enable HTTP chunked transfers </td></tr>
<tr>
<td><code>-H</code> </td><td>add HTTP headers when no URL is specified </td></tr>
<tr>
<td><code>-M</code> </td><td>enable MTOM (application/xop+xml) </td></tr>
<tr>
<td><code>-O opt</code> </td><td>set the XML optional value indicator (default="???") </td></tr>
<tr>
<td><code>-P per</code> </td><td>set the XML element permutation indicator tag (default=<code>__PERMUTE</code>) </td></tr>
<tr>
<td><code>-R rep</code> </td><td>set the XML element repetition indicator tag (default=<code>__REPEAT</code>) </td></tr>
<tr>
<td><code>-S sel</code> </td><td>set the XML element selection indicator tag (default=<code>__SELECT</code>) </td></tr>
<tr>
<td><code>-X uid:pwd</code> </td><td>connect with authentication credentials uid and pwd </td></tr>
<tr>
<td><code>-Y host[:port[:uid:pwd]]</code> </td><td>connect via proxy host, port, and proxy credentials uid and pwd </td></tr>
<tr>
<td><code>infile</code> </td><td>XML message or XML message template with indicator annotations </td></tr>
<tr>
<td><code>-</code> </td><td>instead of infile: read XML message or XML message template from standard input </td></tr>
<tr>
<td><code>URL</code> </td><td>optional endpoint URL of service to test </td></tr>
<tr>
<td><code>port</code> </td><td>optional stand-alone server port for clients to test against </td></tr>
</table>
<p>More specifically, <code>infile</code> is an SOAP/XML message file (or message template file), <code>-</code> specifies that the message should be read from standard input, and <code>URL</code> is the optional service endpoint to send (randomized) messages to. When a <code>port</code> number is specified instead of a URL, testmsgr runs as a stand-alone application to test clients that connect to it. A client application receives the (randomized) message generated by testmsgr from the specified SOAP/XML message file (or message template file).</p>
<h3><code>-a act</code></h3>
<p>Use HTTP SOAP Action header value <code>"act"</code> with the SOAP request messages sent. This option is required for services that require a SOAP Action header.</p>
<h3><code>-b</code></h3>
<p>Add random blank spacing to randomized values when using option <code>-r</code>.</p>
<h3><code>-c</code></h3>
<p>Continuous testing of a service endpoint until the service fails, i.e. until the server at the specified endpoint URL becomes unresponsive.</p>
<h3><code>-d num</code></h3>
<p>Test a service endpoint <code>num</code> times or until the service fails, i.e. until the server at the specified endpoint URL becomes unresponsive.</p>
<h3><code>-f</code></h3>
<p>Exit on any HTTP error or on any SOAP fault by the service endpoint when using option <code>-c</code> or <code>-d num</code>, instead of continuing until the specified endpoint URL becomes unresponsive.</p>
<h3><code>-h</code></h3>
<p>Display help message.</p>
<h3><code>-i</code></h3>
<p>Indent XML with spaces when using option <code>-r</code>.</p>
<h3><code>-j</code></h3>
<p>Indent XML with tabs when using option <code>-r</code>.</p>
<h3><code>-l max</code></h3>
<p>Specifies the max number of randomized element repetitions for <code>__REPEAT</code> and <code>__SELECT</code> with min and max indicators, when using option <code>-r</code>. The default is</p><ol type="1">
<li>The maximum value that can be specified is 18446744073709551615.</li>
</ol>
<h3><code>-m max</code></h3>
<p>Specifies the max length of randomized text values generated when using option <code>-r</code>. The default is 255. The maximum value that can be specified is 18446744073709551615.</p>
<h3><code>-n len</code></h3>
<p>Display the server response up to <code>len</code> bytes. <code>-n0</code> removes the server responses. Omitting this option displays the full response.</p>
<h3><code>-o file</code></h3>
<p>Save output to file. This option is not applicable when <code>URL</code> or <code>port</code> are specified.</p>
<h3><code>-p perc</code></h3>
<p>Retain XML with the specified percentage chance, when using option <code>-r</code>. XML attributes and elements are removed by chance as specified. For example, <code>-p10</code> keeps only roughly 10% of the XML elements and attributes of the original message. The default is 100 (retain all XML).</p>
<h3><code>-q perc</code></h3>
<p>Retain XML qualified with <code>???</code> and elements repeated with the <code>__REPEAT</code> indicator with the specified percentage chance, when using option <code>-r</code>. For example, if a message has an element or attribute value <code>???%[[INT32]]</code> then <code>-q10</code> keeps the element or attribute with a 10% chance. Likewise, optional XML elements enclosed in <code>&lt;__REPEAT&gt;</code> as indicated with <code>min</code> and <code>max</code> bounds are kept with a 10% chance. The default is 100 (retain).</p>
<h3><code>-r seed</code></h3>
<p>Randomize the SOAP/XML message template given as the <code>infile</code> argument. SOAP/XML message templates can be auto-generated with soapcpp2 option <code>-g</code>. The <code>seed</code> value is required and is used to reproduce test messages. Any positive seed value can be specified, from 1 up to 2147483647.</p>
<h3><code>-t sec</code></h3>
<p>Sets a socket idle timeout in seconds. The default is one second. A service is considered unresponsive when a socket timeout occurs while messages are exchanged.</p>
<h3><code>-v</code></h3>
<p>Enable verbose mode.</p>
<h3><code>-A</code></h3>
<p>Use SOAP with MIME attachments, also called SOAP with Attachments (SwA). This option generates a MIME message with SOAP Body and zero or more MIME attachments. When combined with option <code>-r</code>, a MIME attachment is added for each element with binary content (base64Binary XML element) specified in the template with <code>%[[BASE64]]%</code>. The template <code>%[[BASE64]]%</code> value is replaced with an <code>href</code> attribute referencing the MIME attachment with randomized content.</p>
<h3><code>-C</code></h3>
<p>Use HTTP chunked transfers.</p>
<h3><code>-H</code></h3>
<p>Add HTTP headers to the generated message even when no URL is specified on the command line.</p>
<h3><code>-M</code></h3>
<p>Use MTOM (application/xop+xml) messaging. This option generates a MIME message with SOAP Body and zero or more MTOM attachments in MIME format. When combined with option <code>-r</code>, a MIME attachment is added for each element with binary content (base64Binary XML element) specified in the template with <code>%[[BASE64]]%</code>. The template <code>%[[BASE64]]%</code> value is replaced with an <code>&lt;xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include"/&gt;</code> element with an <code>href</code> attribute referencing the MIME attachment with randomized content.</p>
<h3><code>-O opt</code></h3>
<p>Sets the XML optional value indicator. The default is <code>???</code>. See <a class="el" href="index.html#indicators">Element repetition, selection and permutation indicators </a>.</p>
<h3><code>-P per</code></h3>
<p>Sets the XML element permutation indicator tag. The default is <code>__PERMUTE</code>. See <a class="el" href="index.html#indicators">Element repetition, selection and permutation indicators </a>.</p>
<h3><code>-R rep</code></h3>
<p>Sets the XML element repetition indicator tag. The default is <code>__REPEAT</code>. See <a class="el" href="index.html#indicators">Element repetition, selection and permutation indicators </a>.</p>
<h3><code>-S sel</code></h3>
<p>Sets the XML element selection indicator tag. The default is <code>__SELECT</code>. See <a class="el" href="index.html#indicators">Element repetition, selection and permutation indicators </a>.</p>
<h3><code>-X uid:pwd</code></h3>
<p>Sets the basic or http digest authentication credentials.</p>
<h3><code>-Y host:port:uid:pwd</code></h3>
<p>Connect to the server through a proxy server. Sets the proxy host with optional proxy port and optional credentials.</p>
<p>🔝 <a href="#">Back to table of contents</a></p>
<h1><a class="anchor" id="templates"></a>
Message templates                                                   </h1>
<p>A SOAP/XML message template file is required when sending randomized messages with testmsgr option <code>-r</code>. The SOAP/XML message template file can be auto-generated with soapcpp2 option <code>-g</code> on a interface file. This interface file is usually generated with wsdl2h from a (set of) WSDL and XSD file(s). Note that option <code>-g</code> does not produce SOAP/XML message templates if the interface file does not declare any service operations.</p>
<p>🔝 <a href="#">Back to table of contents</a></p>
<h2><a class="anchor" id="placeholder"></a>
Placeholder values                                                </h2>
<p>Templates may contain placeholder values. Placeholder values may start with <code>???</code> meaning the value is optional, followed by the placeholder value type, an enumeration, or a numeric range. Values are inserted with testmsgr option <code>-r seed</code>.</p>
<h3>Optional values</h3>
<p>Element and attributes that are qualified as optional with <code>???</code> are randomly discared with options <code>-r</code> and <code>-q</code>, where <code>-q</code> specifies the percentage of elements and attributes that are retained in the generated XML message. A zero percentage specified with <code>-q0</code> removes all optional values. A value of 100 specified with <code>-q100</code> retains all optional values (the default) in the generated XML message.</p>
<p>The <code>???</code> qualifier may appear after the opening tag of an element (i.e. in front of the element value or child elements) and in attribute values. For example:</p>
<div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;<span class="keywordtype">ns:record</span> <span class="keyword">xmlns:ns</span>=<span class="stringliteral">&quot;urn:example&quot;</span> <span class="keyword">id</span>=<span class="stringliteral">&quot;???[[INT32]]%&quot;</span>&gt;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  &lt;<span class="keywordtype">name</span>&gt;???%[[<span class="keyword">TEXT</span>]]%&lt;/<span class="keywordtype">name</span>&gt;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  &lt;<span class="keywordtype">info</span>&gt;???</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;    &lt;<span class="keywordtype">phone</span>&gt;%[[<span class="keyword">TEXT</span>[1:20]]]%&lt;/<span class="keywordtype">phone</span>&gt;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;    &lt;<span class="keywordtype">email</span>&gt;%[[<span class="keyword">TEXT</span>[1:40]]]%&lt;/<span class="keywordtype">email</span>&gt;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;  &lt;/<span class="keywordtype">info</span>&gt;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;  &lt;<span class="keywordtype">data</span> <span class="keyword">lang</span>=<span class="stringliteral">&quot;%[[LANG]]%&quot;</span>&gt;???&lt;/<span class="keywordtype">data</span>&gt;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;&lt;/<span class="keywordtype">ns:record</span>&gt;</div></div><!-- fragment --> </div><p>where <code>id="???%[[INT32]]"</code> is an optional attribute with a 32-bit integer value, <code>&lt;name&gt;???%[[TEXT]]%&lt;/name&gt;</code> is an optional element with text, <code>&lt;contact&gt;???</code> is an optional element with subelements, and <code>&lt;data lang="%[[LANG]]%"&gt;???&lt;/data&gt;</code> is an optional empty element with an attribute.</p>
<h3>Enumeration placeholders</h3>
<p>Enumeration placeholders can be used anywhere a value is expected and is used to provide an enumeration of possible values to choose from for element and attributes.</p>
<p><code>%[[A][B][C]]%</code> specifies a choice of values <code>A</code>, <code>B</code> or <code>C</code>. The values can be anything but should not contain <code>][</code> or <code>]]%</code>. For example:</p>
<div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;<span class="keywordtype">process</span> <span class="keyword">completed</span>=<span class="stringliteral">&quot;%[[false][true]]%&quot;</span>/&gt;</div></div><!-- fragment --> </div><p>where <code>completed="%[[false][true]]%"</code> enumerates the values <code>false</code> and <code>true</code>. Note that this enumeration is identical to the <code>%[[BOOL]]%</code> placeholder type.</p>
<h3>Pattern placeholders</h3>
<p>Pattern placeholders can be used anywhere a value is expected and is used to provide a pattern to generate randomized values.</p>
<p>A pattern placeholder <code>%[['pattern']]%</code> specifies a pattern in the usual XML regular expression syntax, for example:</p>
<div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;<span class="keywordtype">process</span> <span class="keyword">PID</span>=<span class="stringliteral">&quot;%[[&#39;id[0-9]+&#39;]]%&quot;</span>/&gt;</div></div><!-- fragment --> </div><p>A quote (') in the pattern should be escaped with a backslash as in \', which the soapcpp2 tool automatically converts with option <code>-g</code> to produce pattern facets.</p>
<p>The length of the generated string may be constrained with <code>%[['pattern'[N:M]]]%</code>. The range <code>N:M</code> specifies the number of characters.</p>
<dl class="section note"><dt>Note</dt><dd>Unicode character classes specified with <code>\p{C}</code> are not yet supported in gSOAP versions 2.8.62-2.8.64.</dd></dl>
<dl class="section warning"><dt>Warning</dt><dd>Length constraints <code>N:M</code> in <code>%[['pattern'[N:M]]]%</code> should be viable given the pattern's inherent minimum and maximum lengths. For example, <code>%[['[a-z]+'[0:10]]]%</code> is viable, but <code>%[['id[0-9]{3}'[0:3]]]%</code> is not viable. There is a possibility that the generated pattern does not meet the <code>[N:M]</code> constraints provided.</dd></dl>
<h3>Numeric range and precision placeholders</h3>
<p>A numeric range is integer-valued when the lower bound <code>N</code> and upper bound <code>M</code> are integer. Otherwise, the numeric range values are floating point. For example, <code>%[[0:10]]%</code> speficies a range of integer values whereas <code>%[[0.0:10.0]]%</code> specifies a range of floating point values. The bounds of a numeric range can be made exlusive by using <code>(</code> and <code>)</code> instead of <code>[</code> and <code>]</code>.</p>
<p><code>%[[N:M]]%</code> specifies a range of integer or float values between <code>N</code> and <code>M</code>.</p>
<p><code>%[[N:M)]%</code> specifies a range of integer or float values between <code>N</code> and <code>M</code> (exclusive).</p>
<p><code>%[(N:M]]%</code> specifies a range of integer or float values between <code>N</code> (exclusive) and <code>M</code>.</p>
<p><code>%[(N:M)]%</code> specifies a range of integer or float values between <code>N</code> (exclusive) and <code>M</code> (exclusive).</p>
<p>For example:</p>
<div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;<span class="keywordtype">price</span>&gt;%[(0.00:100000.00]]%&lt;/<span class="keywordtype">price</span>&gt;</div></div><!-- fragment --> </div><p>where 0.00 is excluded from the float value range and <code>100000.00</code> is the inclusive maximum of the numeric range.</p>
<p>A decimal precision is specified with a printf-based format string, such as <code>%.2f</code> to indicate 2 decimal places after the decimal period should be used. The decimal precision is added to the range in the template. For example, <code>%[[0.0:999.0%.2f]]%</code> specifies a floating point range between 0.00 and 999.00 with 2 decimal places after the period. The total field width (total digits) can be specified with <code>%[[0.0:999.0%6.2f]]%</code> for example.</p>
<p>The precision of a "limitless" floating point and double precision floating point numeric precision is specified with <code>%[[FLOAT%.2e]]%</code> and <code>%[[DOUBLE%.2e]]%</code> respectively. This produces numeric values within the range of the specified type formatted according to the specified printf-format string.</p>
<h3>Primitive XSD type value placeholders</h3>
<p><code>%[[BASE64]]%</code> and length-restricted <code>%[[BASE64[N:M]]]%</code> specify xsd:base64Binary XSD values. The length restriction <code>N:M</code> specifies the range of base64-encoded bytes.</p>
<p><code>%[[BOOL]]%</code> specifies xsd:boolean XSD values.</p>
<p><code>%[[DATE]]%</code> specifies xsd:date XSD values.</p>
<p><code>%[[DATETIME]]%</code> specifies xsd:dateTime XSD values.</p>
<p><code>%[[DOUBLE]]%</code> specifies xsd:double XSD values.</p>
<p><code>%[[DURATION]]%</code> specifies xsd:duration XSD values.</p>
<p><code>%[[ENTITY]]%</code> and length-restricted <code>%[[ENTITY[N:M]]]%</code> specify xsd:ENTITY XSD values. The range <code>N:M</code> specifies the number of characters.</p>
<p><code>%[[HEX]]%</code> and length-restricted <code>%[[HEX[N:M]]]%</code> specify xsd:hexBinary XSD values. The length restriction <code>N:M</code> specifies the range of encoded bytes, not the number of hexadecimal characters.</p>
<p><code>%[[ID]]%</code> and length-restricted <code>%[[ID[N:M]]]%</code> specify xsd:ID XSD values. The range <code>N:M</code> specifies the number of characters.</p>
<p><code>%[[IDREF]]%</code> and length-restricted <code>%[[IDREF[N:M]]]%</code> specify xsd:IDREF XSD values. The range <code>N:M</code> specifies the number of characters.</p>
<p><code>%[[FLOAT]]%</code> specifies xsd:float XSD values.</p>
<p><code>%[[INT8]]%</code> and <code>%[[BYTE]]%</code> specify xsd:byte XSD values.</p>
<p><code>%[[INT16]]%</code> and <code>%[[SHORT]]%</code> specify xsd:short XSD values.</p>
<p><code>%[[INT32]]%</code> and <code>%[[INT]]%</code> specify xsd:int XSD values.</p>
<p><code>%[[INT64]]%</code> and <code>%[[LONG]]%</code> specify xsd:long XSD values.</p>
<p><code>%[[LANG]]%</code> specifies xsd:language XSD values.</p>
<p><code>%[[NAME]]%</code> and length-restricted <code>%[[NAME[N:M]]]%</code> specify xsd:Name XSD values. The range <code>N:M</code> specifies the number of characters.</p>
<p><code>%[[NCNAME]]%</code> and length-restricted <code>%[[NCNAME[N:M]]]%</code> specify xsd:NCName XSD values. The range <code>N:M</code> specifies the number of characters.</p>
<p><code>%[[NMTOKEN]]%</code> and length-restricted <code>%[[NMTOKEN[N:M]]]%</code> specify xsd:NMTOKEN XSD values. The range <code>N:M</code> specifies the number of characters.</p>
<p><code>%[[QNAME]]%</code> specifies xsd:QName XSD values.</p>
<p><code>%[[TEXT]]%</code> and length-restricted <code>%[[TEXT[N:M]]]%</code> specify xsd:string, xsd:normalizedString, xsd:anyURI, xsd:NOTATION, and xsd:token XSD values. The range <code>N:M</code> specifies the number of characters.</p>
<p><code>%[[TIME]]%</code> specifies xsd:time XSD values.</p>
<p><code>%[[TOKEN]]%</code> and length-restricted <code>%[[TOKEN[N:M]]]%</code> specify xsd:token XSD values. The range <code>N:M</code> specifies the number of characters.</p>
<p><code>%[[UINT8]]%</code> and <code>%[[UBYTE]]%</code> specify xsd:unsignedByte XSD values.</p>
<p><code>%[[UINT16]]%</code> and <code>%[[USHORT]]%</code> specify xsd:unsignedShort XSD values.</p>
<p><code>%[[UINT32]]%</code> and <code>%[[UINT]]%</code> specify xsd:unsignedInt XSD values.</p>
<p><code>%[[UINT64]]%</code> and <code>%[[ULONG]]%</code> specify xsd:unsignedLong XSD values.</p>
<p><code>%[[URI]]%</code> specifies xsd:anyURI XSD values.</p>
<p>🔝 <a href="#">Back to table of contents</a></p>
<h2><a class="anchor" id="indicators"></a>
Element repetition, selection and permutation indicators           </h2>
<p>Three special XML elements <code>__REPEAT</code>, <code>__SELECT</code> and <code>__PERMUTE</code> in message templates indicate XML element repetitions and selections, respectively. These elements are processed by the Test Messenger to generate child elements, after which the <code>__REPEAT</code>, <code>__SELECT</code> and <code>__PERMUTE</code> XML elements are removed from the generated randomized XML messages.</p>
<p>These indicators require testmsgr option <code>-r seed</code>.</p>
<h3>Repetition</h3>
<p>Child elements and/or CDATA text in the <code>__REPEAT</code> indicator element are repeated within a range specified by <code>min</code> and <code>max</code> attributes of the <code>__REPEAT</code> element. The <code>min</code> and <code>max</code> attributes are optional and default to 1 when omitted.</p>
<p>Option <code>-q</code> of testmsgr controls the percentage of child elements that are generated within the range. A zero percentage specified with <code>-q0</code> generates the minimum number of child elements. A value of 100 specified with <code>-q100</code> generates the maximum number of child elements. The maximum number of child elements (randomly) generated is bounded by option <code>-l</code> (default is 3). Therefore, the maximum number of child elements is the greater of attribute <code>min</code> and the lesser of attribute <code>max</code> and the value <em>lmax</em> specified with option <code>-l</code>:</p>
<blockquote class="doxtable">
<p><em>min &lt;= n &lt;= maximum(min, minimum(max, lmax))</em> </p>
</blockquote>
<p>where <em>n</em> is the number of child elements generated with a random probability percentage specified by option <code>-q</code>.</p>
<p>For example, to repeat an <code>item</code> element with an integer value two or more times use the <code>__REPEAT</code> indicator element with <code>item</code> as a child element:</p>
<div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;<span class="keywordtype">__REPEAT</span> <span class="keyword">min</span>=<span class="stringliteral">&quot;2&quot;</span> <span class="keyword">max</span>=<span class="stringliteral">&quot;unbounded&quot;</span>&gt;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  &lt;<span class="keywordtype">item</span>&gt;%[[<span class="keyword">INT32</span>]]%&lt;/<span class="keywordtype">item</span>&gt;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;&lt;/<span class="keywordtype">__REPEAT</span>&gt;</div></div><!-- fragment --> </div><p>Assuming that testmsgr options <code>-r1</code>, <code>-l10</code> and <code>-q50</code> are used, the generated XML message has at least two <code>item</code> elements and at most 10 elements, with on average 50% of the elements kept between 2 (the <code>min</code> minimum) and 10 elements (the maximum specified by <code>-l10</code>), i.e. 6 elements on average. Each <code>item</code> element has a random integer value.</p>
<p>Multiple child elements can be repeated as a group, which may include mixed CDATA content of any type, for example:</p>
<div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;<span class="keywordtype">__REPEAT</span> <span class="keyword">min</span>=<span class="stringliteral">&quot;0&quot;</span> <span class="keyword">max</span>=<span class="stringliteral">&quot;10&quot;</span>&gt;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  &lt;<span class="keywordtype">product</span>&gt;%[[<span class="keyword">TOKEN</span>]]%&lt;/<span class="keywordtype">product</span>&gt;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  &lt;<span class="keywordtype">number</span>&gt;???%[[<span class="keyword">INT32</span>]]%&lt;/<span class="keywordtype">number</span>&gt;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;  %[[<span class="keyword">HEX</span>]]%</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;&lt;/<span class="keywordtype">__REPEAT</span>&gt;</div></div><!-- fragment --> </div><p>This repeats <code>&lt;product&gt;</code> with optional <code>&lt;number&gt;</code> up to 10 times, with mixed hexadecimal text included.</p>
<p>Note that the <code>???</code> qualifier can be used with child elements to make them optional in repetitions as shown in the example.</p>
<p>The testmsgr tool recognizes SOAP 1.1/1.2 arrays with array type and size attributes. These attributes are automatically changed in the randomized XML output. The array element should have one or more nested <code>__REPEAT</code> indicators. Consider for example the following 2D array:</p>
<div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;<span class="keywordtype">arrayOfFloat</span> <span class="keyword">xsi:type</span>=<span class="stringliteral">&quot;SOAP-ENC:Array&quot;</span> <span class="keyword">SOAP-ENC:arrayType</span>=<span class="stringliteral">&quot;float[1,1]&quot;</span>&gt;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  &lt;<span class="keywordtype">__REPEAT</span> <span class="keyword">min</span>=<span class="stringliteral">&quot;0&quot;</span> <span class="keyword">max</span>=<span class="stringliteral">&quot;4&quot;</span>&gt;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  &lt;<span class="keywordtype">__REPEAT</span> <span class="keyword">min</span>=<span class="stringliteral">&quot;0&quot;</span> <span class="keyword">max</span>=<span class="stringliteral">&quot;8&quot;</span>&gt;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;    &lt;<span class="keywordtype">item</span>&gt;%[[<span class="keyword">FLOAT</span>]]%&lt;/<span class="keywordtype">item</span>&gt;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;  &lt;/<span class="keywordtype">__REPEAT</span>&gt;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;  &lt;/<span class="keywordtype">__REPEAT</span>&gt;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;&lt;/<span class="keywordtype">arrayOfFloat</span>&gt;</div></div><!-- fragment --> </div><p>The <code>SOAP-ENC:arrayType</code> attribute array dimension values are automatically adjusted in the XML output by testmsgr depending on the number of <code>item</code> elements generated.</p>
<h3>Selection</h3>
<p>One child element of the <code>__SELECT</code> indicator element is uniform randomly selected as an XML element for the generated randomized XML message.</p>
<p>For example, to select one element from the three choices of elements <code>A</code>, <code>B</code> or <code>C</code>:</p>
<div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;<span class="keywordtype">__SELECT</span>&gt;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  &lt;<span class="keywordtype">A</span>&gt;%[[<span class="keyword">INT32</span>]]%&lt;/<span class="keywordtype">A</span>&gt;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  &lt;<span class="keywordtype">B</span>&gt;%[[<span class="keyword">FLOAT</span>]]%&lt;/<span class="keywordtype">B</span>&gt;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;  &lt;<span class="keywordtype">C</span>&gt;%[[<span class="keyword">TEXT</span>]]%&lt;/<span class="keywordtype">C</span>&gt;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;&lt;/<span class="keywordtype">__SELECT</span>&gt;</div></div><!-- fragment --> </div><p>The generated XML message has either an <code>A</code> element with an integer value, a <code>B</code> element with a floating point value, or a <code>C</code> element with a text value.</p>
<p>Note that the <code>???</code> qualifier can be used with child elements to make them optional in selections.</p>
<h3>Permutation</h3>
<p>Child element of the <code>__PERMUTE</code> indicator element are uniform randomly permuted in the generated randomized XML message.</p>
<p>For example, elements <code>A</code>, <code>B</code> or <code>C</code> are permuted with:</p>
<div class="alt"> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;&lt;<span class="keywordtype">__PERMUTE</span>&gt;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;  &lt;<span class="keywordtype">A</span>&gt;%[[<span class="keyword">INT32</span>]]%&lt;/<span class="keywordtype">A</span>&gt;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;  &lt;<span class="keywordtype">B</span>&gt;%[[<span class="keyword">FLOAT</span>]]%&lt;/<span class="keywordtype">B</span>&gt;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;  &lt;<span class="keywordtype">C</span>&gt;%[[<span class="keyword">TEXT</span>]]%&lt;/<span class="keywordtype">C</span>&gt;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;&lt;/<span class="keywordtype">__PERMUTE</span>&gt;</div></div><!-- fragment --> </div><p>The generated XML message has <code>A</code>, <code>B</code> and <code>C</code> elements produced in any order.</p>
<p>Note that the <code>???</code> qualifier can be used with child elements to make them optional in permutations.</p>
<p>🔝 <a href="#">Back to table of contents</a></p>
<h1><a class="anchor" id="copyright"></a>
Copyright                                                           </h1>
<p>Copyright (c) 2018, Robert van Engelen, Genivia Inc. All rights reserved. </p>
</div></div><!-- contents -->
<hr class="footer">
<address class="footer">
Copyright (C) 2020, Robert van Engelen, Genivia Inc., All Rights Reserved.
</address>
<address class="footer"><small>
Converted on Sun Feb 16 2020 15:07:53 by <a target="_blank" href="http://www.doxygen.org/index.html">Doxygen</a> 1.8.11</small></address>
<br>
<div style="height: 246px; background: #DBDBDB;">
</body>
</html>
